class CommentableshipsController < ApplicationController
	before_filter :login_required
	
	def create
		if !params[:commentable_id].nil? and !params[:commentable_type].nil?
			c = Commentableship.find(:first, :conditions => {:user_id => current_user.id, :commentable_type => params[:commentable_type], :commentable_id => params[:commentable_id]})
			if !c.nil?
				if !params[:is_watching].nil? && params[:is_watching]
					c.is_watching = true
				else
					c.is_watching = false
				end
				c.save
			end
		end
		render :nothing => true
	end
	
	def destroy
		if (!params[:commentable_id].nil?) and (!params[:commentable_type].nil?)
			commentableship = Commentableship.find(:first, :conditions => ["user_id = ? and commentable_id = ? and commentable_type = ?", current_user.id, params[:commentable_id], params[:commentable_type]])
			commentableship.destroy
		end
		render :nothing => true
	end	 
end
